import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BillRuleVO, BillRuleForm, BillRuleQuery } from '@/api/system/billRule/types';

/**
 * 查询单据规则列表
 * @param query
 * @returns {*}
 */

export const listBillRule = (query?: BillRuleQuery): AxiosPromise<BillRuleVO[]> => {
  return request({
    url: '/system/billRule/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询单据规则详细
 * @param id
 */
export const getBillRule = (id: string | number): AxiosPromise<BillRuleVO> => {
  return request({
    url: '/system/billRule/' + id,
    method: 'get'
  });
};

/**
 * 新增单据规则
 * @param data
 */
export const addBillRule = (data: BillRuleForm) => {
  return request({
    url: '/system/billRule',
    method: 'post',
    data: data
  });
};

/**
 * 修改单据规则
 * @param data
 */
export const updateBillRule = (data: BillRuleForm) => {
  return request({
    url: '/system/billRule',
    method: 'put',
    data: data
  });
};

/**
 * 删除单据规则
 * @param id
 */
export const delBillRule = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/billRule/' + id,
    method: 'delete'
  });
};
